package org.example.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.example.dao.UserDao;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import javax.sql.DataSource;

//@Configuration 这个配置类代表配置文件，但是导入后的配置文件就不需要了
public class JdbcConfig {
    @Value("${jdbc.driver}")
    private String driver;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.Username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;
    @Bean
    public DataSource dataSource()
    {
        DruidDataSource dragSource = new DruidDataSource();
        dragSource.setDriverClassName(driver);
        dragSource.setUrl(url);
        dragSource.setUsername(username);
        dragSource.setPassword(password);
        return dragSource;
    }
}
